The present invention relates to computer systems and, more particularly, to memory management of networked computer systems.
A dynamic run-time environment for a language such as JAVA(trademark) is responsible for managing memory for objects that are created and destroyed during the execution of a program. An object is an entity that encapsulates data and, in some languages, operations associated with the object. Since the encapsulated data is stored in memory, objects are associated with particular regions of memory that are allocated and deallocated by the dynamic run-time environment.
The state of a program, or xe2x80x9cprogram state,xe2x80x9d is the set of the objects and the references between the objects that exist at a specific point in time during the execution of the program. A xe2x80x9creferencexe2x80x9d is used by a run-time environment to identify and ultimately access the region of memory for storing the data of the object. Typically, references between objects in a run-time environment are encoded using machine pointers. A machine pointer is a native datum that contains the address of the object in the main memory, which can be a real memory address or, more commonly, a virtual address on a machine that implements a virtual memory system.
xe2x80x9cVirtual memoryxe2x80x9d refers to memory addressable by a storage allocation technique in which auxiliary storage, such as memory on a hard disk, can be addressed as though it were part of the main memory such as a RAM. More specifically, combinations of hardware, firmware, and operating system cooperate to automatically swap portions of the code and data for an executing process on an as-needed basis. Thus, the virtual address space may be regarded as addressable main memory to a process executing on a computer system that maps virtual addresses into real addresses. The size of the virtual address space is usually limited by the size of a native machine pointer, but not by the actual number of storage elements in main memory.
A virtual address space is typically subdivided into a plurality of fixed-size contiguous sections of memory called xe2x80x9cpages.xe2x80x9d Typically, some of the virtual memory pages for a process are specific to the process and cannot be shared with other processes, but, in some implementations, other virtual memory pages can be shared globally with other processes.
One popular run-time environment is a JAVA(trademark) virtual machine, which supports a platform-independent, object-oriented language developed by Sun Microsystems. In JAVA, the attributes and methods for a class of objects are typically defined in a source file, which is compiled into an architecture-neutral object file containing bytecodes that are interpreted in the virtual machine at the target platform. It is common for objects to reference other objects.
Lately, there has been much interest in using JAVA in a multi-user environment that allows multiple users to connect in separate, concurrent sessions to a server system, such as a relational database system. When designing a run-time environment for such a multi-user environment, scalability in terms of the number of simultaneous users who can establish separate sessions is very important.
A significant constraint for user scalability is the size of the memory xe2x80x9cfootprintxe2x80x9d that each session consumes. For example, a server system may have 100 Mb of memory for supporting all the user sessions. If the session memory footprint is 1 Mb, then only 100 user sessions can be supported at one time. Therefore, it is desirable to reduce the session memory footprint to improve scalability.
One approach for reducing the session memory footprint in a run-time environment is to allocate a single copy of objects, code, and data in a globally shared read-only memory rather than in a session memory that is devoted to a single session. In the example, if 500 Kb of the 1 Mb session memory footprint can be shared between the different sessions, then 500 Kb of the total 100 Mb can be reserved as a global shared read-only memory, and the remaining the 99.5 Mb would available for the individual session memories. Since the session memory requirements has dropped to 500 Kb, a total of 199 user sessions can now be supported. Consequently, session memory reduction by using globally shared read-only memory is a promising approach for improving scalability of the multi-user run-time environment.
In many systems, objects, code and data are placed into the globally shared read-only memory only at load time and therefore cannot be modified after being loaded. This approach for reducing the session memory footprint, however, has not conventionally been feasible for those objects that are good candidates for sharing but require construction in a run-time environment even though they are not later modified. Many of these objects, for example, are class objects found in the Java system classes, which construct objects during class initialization (clinit). In addition, other kinds of these objects can be found in user code. Consequently, these objects are not placed in globally shared, read-only memory and consume valuable session memory.
Therefore, there is a need to reduce the session memory footprint for such objects to improve scalability.
This need and others are addressed by the present invention, in which class objects such as static variables are constructed in a memory as normal, but saved, for example to disk, in their constructed state. The constructed class objects can be loaded, for example from disk, directly into a globally shared memory, thereby avoid subsequent constructions of the same object and improving performance.
Accordingly, one aspect of the invention relates to a method and software for managing a run-time environment. A class file is loaded, the class file specifying a class that includes a static class variable and a static initializer to initialize the static class variable. The static initializer is then invoked to initialize the static class variable. The class and the initialized static class variable are then saved in a second class file. The second class file is then loaded into a shared memory, the second class file including the class and the initialized static class variable.
Another embodiment pertains to a method and software for managing a run-time environment, wherein an object and a name for the object are registered in shared memory. The method starts by specifying an object for migration. In a first process of the method, the object and a name for the object are registered, the object is migrated into a shared memory, and the object is stored in a database. In a second process of the method, the object is loaded into the shared memory from the database based on the name of the object.
Advantageously, the present invention makes it simple for system developers to reduce session footprint size of any large, read-only class state by making better use of shared memory. For objects that are sharable by many users, one copy of the object is put into shared read only memory so that objects do not unnecessarily fill up session memory of each user.
Still other objects and advantages of the present invention will become readily apparent from the following detailed description, simply by way of illustration of the best mode contemplated of carrying out the invention. As will be realized, the invention is capable of other and different embodiments, and its several details are capable of modifications in various obvious respects, all without departing from the invention. Accordingly, the drawing and description are to be regarded as illustrative in nature, and not as restrictive.